package com.ogawa.base.download;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.ogawa.base.R;


/**
 * 更新进度条
 * Created by fhb on 2016/4/7.
 *
 */
public class AlertDialogUpdataProgress extends Dialog {
    private TextView mTvDownLoadSize;
    private TextView mTvPrecent;
    private TextView mTvContent;
    private ProgressBar mProgress;
    private Context mContext;
    private String mContent;


    //定义回调事件，用于dialog的点击事件
    public interface OnDialogListener{
             void onClick();
    }


    /**
     * 对话框
     * @param context

     */
    public AlertDialogUpdataProgress(Context context,String content) {
            super(context, R.style.BaseDialog);
        mContext = context;
        mContent = content;
        if(mTvContent!=null){
            mTvContent.setText(mContent+"");
        }

    }
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            	//去掉Title
            AlertDialogUpdataProgress.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.dialog_updata_loading);
        mTvContent =  findViewById(R.id.updata_downloading_content1);
           mTvPrecent      =  findViewById(R.id.tv_progress);
           mProgress    =findViewById(R.id.updata_downloading_pb);
        mTvContent.setText(mContent+"");

    }

    public void refreshView(String size, String precent, String speed, int progress){

        mTvPrecent.setText(mContext.getString(R.string.download_progress, progress));
        mProgress.setProgress(progress);

    }

}
